London Class 7 - Hozan Ali - JavaScript-Core-1-Coursework - Week 1#52
London Class 7 - Hozan Ali - JavaScript-Core-1-Coursework - Week 1#52Hozan94 wants to merge 3 commits into
Conversation
Solving all question in the 'exercise' and 'mandatory' folders.
| var myName = "Hozan"; | ||
| var nameLength = myName.length; | ||
| var message = "My name is " + myName + " and my name is " + nameLength + " characters long"; |
There was a problem hiding this comment.
This looks great Hozan! As a challenge, you can make use of template literals. This link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals and video: https://youtu.be/NgF9-pdTDGs are quite useful should you need them.
There was a problem hiding this comment.
Thanks for the feedback Omar, the documents you provided looks great, I already went through them and found some useful info, I want to also note that in some exercises I did apply template literals, while in others I left them to have string literlas just so I practice how to use them both. Many Thanks
| @@ -1,3 +1,4 @@ | |||
| const name = " Daniel "; | |||
| var message = "My name is " + name.trim() + " and my name is " + name.length + " characters long"; | |||
There was a problem hiding this comment.
Very well done on your work Hozan, impressive!
only one very personal suggestion, you could have used a variable to hold the trimmed value and then use it. That would had simplify your code. Now is a bit compacted, which again, is a personal choice. I read it better on multiple lines.
There was a problem hiding this comment.
Many thanks @Domenico-cyf for your feedback, I will consider such thing next time, as I was only trying to minimize my code.
| return Math.random() * 10; | ||
| } | ||
| // The function above will return a random integer from 0 and 9, The random() method returns a random number from 0 (inclusive) up to but not including 1 (exclusive) | ||
|
|
There was a problem hiding this comment.
Hi Hozan, when if you run Math.random what output do you get? If you multiple the result of Math.random with 10 does it result in an integer?
There was a problem hiding this comment.
Hi @louisechow , many thanks for the feedback.
You are right, I should have worded my answer properly.
The Math.random method will return a floating point number between 0 and 1 (not included), and when it is multiplied by 10 we will still get a floating point number between 0 and 10 (not included).
| function s(w1, w2) { | ||
| return w1.concat(w2); | ||
| } | ||
| // The concat() method above is used to join two or more strings, so the function will return a new string of w1 + w2. |
There was a problem hiding this comment.
The function s only has 2 arguments, so you can't join more than 2 strings.
There was a problem hiding this comment.
@louisechow you are right, I should be careful with how I write my answer, in that particual example it will only be used to concatenate the two parameters w1 and w2.
|
Great work Hozan! 👏 |
|
Your coursework submission has been closed because nobody has interacted with it in 30 days. You are welcome to re-open it to get more feedback. |
Solving all question in the 'exercise' and 'mandatory' folders.
Your Details
Homework Details